//
// Created by hsj on 2022/3/8.
//

#include "t_str_file.h"
namespace t_str_file_test{
    void test(){
        using namespace std;
        ifstream fin;
        fin.open("tobuy.txt");
        //校验可以打开吗
        if (!fin.is_open()){
            cout<<"Can not open file. will exit..."<<endl;
            exit(EXIT_FAILURE);
        }
        //
        string item;
        int count = 0;
        getline(fin,item,':');
        //输入正确
        while (fin){
            ++count;
            cout<<"count:"<<item<<endl;
            //下一轮
            getline(fin,item,':');
        }

        cout<<"Done finish."<<endl;
        //文件流关闭
        fin.close();
    }
}